<template>
	<view>
		<view class="item_content">
			<view style="margin-bottom: 50rpx;">
				<view class="con_img">
					<image :src="BASE_IMG_URL+'headImg.png'"  mode="scaleToFill"></image>
				</view>
				<view class="con_main">
					<view class="main_first">
						<view style="color: #333;font-size: 30rpx;">{{info && info.followup_staff && info.followup_staff.trueName}}</view>
						<view class="lxs_time" style="font-size: 30rpx ;color: #999;">{{''|| info.followup_finish_time }}</view>
					</view>
					<view class="main_type daofang" v-if="info && info.followup_type == '0'"><span>日常回访</span>
					</view> 
				</view>
			</view>

			<view class="main_second">
				<view>{{info.followup_content ||''}}</view>
			</view>
			<view class="main_third fontColor">
				下次跟进时间：{{info.next_followup_time ||''}}
			</view>
			
		</view>
		<view class="comment">
			<image :src="BASE_IMG_URL+'pl.png'"  mode="scaleToFill"></image>
			<view class="span">
				({{commont_list.length}})
			</view>
		</view>
		<!-- 导航栏 -->
		<view class="detail_tab">
			<view class="comment_list">
				<view class="content" v-for="(item,index) in commont_list" :key="index">
					<image class="image" :src="BASE_IMG_URL+'headImg.png'"
						 mode="scaleToFill"></image>
					<view class="main_first">
						<view style="font-size: 30rpx;color: #333;padding-top: 30rpx;">{{item.staff_name}}</view>
						<!-- <view class="fontColor">{{item.staff.post}}</view> -->
						<view style="font-size: 24rpx;color: #999;margin-top: 15rpx;">{{item.addTtime}}</view>
					</view>
					<view class="main_second">
						<text style="word-break:break-all;text-indent:25rpx">{{item.content}}</text>
					</view>
				</view>
				<view style="height: 200rpx;"></view>
				<u-empty v-if="commont_list.length == 0" text="暂无更多"></u-empty>
			</view>
		</view>
		<view class="bottom_nav">
			<view class="textArea">
				<input type="text" v-model="content" style="height: 80rpx;line-height: 80rpx;font-size: 28rpx;"
					placeholder-style="font-size:28rpx;color:#999;" placeholder="请填写评论" value="" />
				<view class="fabu" @click="$noMultipleClicks(btnPubClick)">
					<image style="width: 46rpx;height: 42rpx;" :src="BASE_IMG_URL+'fabu.png'"  mode="scaleToFill"></image>
					发布
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		netFollowRecordDetail,
		netAddComment,
		netGetCommentList
	} from '@/api/kehu.js'
	import {
		BASE_IMG_URL
	} from '@/util/api.js'
	export default {
		data() {
			return {
				noClick: true, //防止重复点击
				popupShow: false,
				id: '',
				info: null,
				content: '',
				commont_list: [], //评论列表
				BASE_IMG_URL: BASE_IMG_URL,
			}
		},
		onLoad(options) {
			this.id = options.followup_id
			
		},
		onShow() {
			this.getInfo()

		},
		created() {

		},
		methods: {
			getInfo() {
				netFollowRecordDetail({
					followup_id: this.id
				}).then(res => {
					this.info = res.data
					if(this.info){
						// 获取  评论 列表
						this.getCommont()
					}
					
				})
			},
			getCommont() {
				netGetCommentList({
					record_id: this.id,
					type: 2
				}).then(res => {
					this.commont_list = res.data
					uni.$emit("handClick",{//点击返回的这个页面触发一个事件，使用uni.$emit(“handClick”,{})
							rightText: this.commont_list.length, //传递的参数
						});

				})
			},
			publishClick() {
				this.popupShow = true
			},
			closePup() {
				this.popupShow = false
			},
			//发布 评论
			btnPubClick() {
				if (!this.content) {
					uni.showToast({
						title: '请填写评论',
						icon: 'none'
					})
					return
				}
				let params = {
					content: this.content,
					record_id: this.id,
					type: 2 
				}
				netAddComment(params).then(res => {
					uni.showToast({
						title: res.message,
						icon: 'none'
					})
					setTimeout(() => {
						this.content = ''
						this.popupShow = false
						this.getCommont()
					}, 2000)
				})

			},
		}
	}
</script>

<style lang="scss" scoped>
	.item_content {
		margin-top: 20rpx;
		background: #fff;

		.con_img {
			float: left;
			image {
				width: 130rpx;
				height: 130rpx;
				border-radius: 50%;
				margin: 30rpx 25rpx 35rpx 50rpx;
			}
		}

		.con_main {
			padding-top: 45rpx;

			.main_first {
				display: flex;
				justify-content: space-between;
				padding-right: 30rpx;
			}

			.main_type {
				margin-top: 30rpx;

				span {
					font-size: 26rpx;
					color: #03AA96;
					padding: 5rpx 12rpx;
					background: rgba(3, 170, 150, .1);
					border-radius: 5rpx;
				}
			}
		}

		.main_second {
			font-size: 30rpx;
			color: #666;
			margin-left: 35rpx;
			margin-bottom: 20rpx;
		}

		.main_third {
			font-size: 30rpx;
			color: #999999;
			padding-left: 35rpx;
			padding-bottom: 30rpx;
		}

	}

	.comment {
		height: 90rpx;
		background: #fff;
		border-top: 1rpx solid #ededed;
		text-align: center;

		image {
			width: 40rpx;
			height: 36rpx;
			margin: 35rpx 0 0 330rpx;
			float: left;
		}

		.span {
			float: left;
			width: 100rpx;
			line-height: 90rpx;
		}
	}

	.detail_tab {
		.comment_list {
			margin-bottom: 50rpx;

			.content {
				background: #fff;
				border-bottom: 1px solid #ededed;
				padding-bottom: 30rpx;

				&:first-child {
					margin-top: 20rpx;
				}
				&:last-child{
					margin-bottom: 120rpx;
				}

				.image {
					float: left;
					width: 80rpx;
					height: 80rpx;
					border-radius: 50%;
					margin: 30rpx;
				}

				.main_first {
					padding-bottom: 20rpx;
				}

				.main_second {
					width: 600rpx;
					margin: 0 auto;
					font-size: 26rpx;
					color: #999;
					padding: 30rpx;

					text {
						line-height: 30rpx;
					}
				}
			}

		}
	}


	.bottom_nav {
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		padding: 20rpx 0;
		background-color: #fff;
		text-align: center;
		color: #999;

		.bottom_item {
			width: 680rpx;
			height: 80rpx;
			border-radius: 40rpx;
			text-align: center;
			line-height: 80rpx;
			background: #03aa96;
			color: #fff;
			font-size: 26rpx;
			margin: 0 auto;
		}
	}

	.textArea {
		display: flex;
		justify-content: space-around;
		input {
			width: 500rpx;
			height: 54rpx;
			border-radius: 10rpx;
			font-size: 24rpx;
			color: #333;
			border: 1rpx solid #EAEAEA;

		}

		.fabu {
			margin-top: 25rpx;
			font-size: 30rpx;
			color: #333;

			image {
				float: left;
				margin-right: 20rpx;
			}
		}
	}
</style>
